{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import joblib\n",
    "import pandas as pd\n",
    "import os"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "valid_id =joblib.load('../../scrum_data/valid_data/valid_id.lz4')\n",
    "\n",
    "data_nodup = joblib.load('../../scrum_data/valid_data/valid_nodup.lz4')\n",
    "data_tag = joblib.load('../../scrum_data/valid_data/valid_tag.lz4')\n",
    "data_date = joblib.load('../../scrum_data/valid_data/valid_date.lz4')\n",
    "data_week =joblib.load('../../scrum_data/valid_data/valid_week.lz4')\n",
    "data_null_sign = joblib.load('../../scrum_data/valid_data/valid_null_sign90.lz4')\n",
    "data_majcnt = joblib.load('../../scrum_data/valid_data/valid_majcnt.lz4')\n",
    "data_cf_fs = joblib.load('../../scrum_data/valid_data/valid_cf_86_fs10.lz4')\n",
    "\n",
    "data = pd.concat([data_nodup,data_tag,data_date,data_week,data_null_sign,data_majcnt,data_cf_fs],axis=1,copy=False)\n",
    "x_test = data.fillna(-1)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "def predict_prob(model,x_test,test_id):\n",
    "    pred = pd.DataFrame()\n",
    "    pred['id'] = test_id\n",
    "    pred['prob'] = model.predict(x_test)\n",
    "    return pred"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "model_list = os.listdir('./models/')\n",
    "for model_name in model_list:\n",
    "    model = joblib.load(os.path.join('./models',model_name))\n",
    "    pred = predict_prob(model,x_test,valid_id)\n",
    "    pred.to_csv('./preds/{}_pred'.format(model_name),index=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
